package com.example.demo10;

import android.app.Activity;
import android.os.Build;

import androidx.annotation.RequiresApi;

import java.util.ArrayList;
import java.util.List;

public class ActivityMange {
    private static List<Activity> activityList  = new ArrayList<>();

    public static void add(Activity activity){
        activityList.add(activity);
    }

    public static void remove(Activity activity){
        activityList.remove(activity);
    }

    @RequiresApi(api = Build.VERSION_CODES.N)
    public static void finish(){

        activityList.forEach((Activity activity)->{
            if (activity!=null)
            activity.finish();
        });
    }
}
